#ifndef _CLINT_H_
#define _CLINT_H_

#include "device/Device.h"

#define CLINT_BASE 0x02000000
#define CLINT_SIZE 0x0000C000

#define     CLINT_MTIMECMP_OFFSET   0x4000
#define     CLINT_MTIME_OFFSET      0xBFF8

class CLINT : public Device {
private:
    uint64_t mtimecmp;
    uint64_t mtime;
    uint32_t msip;
public:
    CLINT();
    void tick();
    bool read(word_t start_addr, size_t length, uint8_t* buffer) override;
    bool write(word_t start_addr, size_t length, const uint8_t* buffer) override;
    void update() override;
    bool msi();
    bool mti();
};

#endif
